package com.taplinker.client.im.activity.message;

import java.util.HashMap;

import android.content.Context;
import android.view.View;

import com.taplinker.client.im.protocol.TapLinkerMessage;

public class ChatMessageFactory {

	static HashMap<Integer, AbstractMessageView> viewMap = new HashMap<Integer, AbstractMessageView>();
	static {
		viewMap.put(MessageTypeEnum.LEFT_TEXT.getTypeNo(),
				new LeftTextMessage());
		viewMap.put(MessageTypeEnum.RIGHT_TEXT.getTypeNo(),
				new RightTextMessage());
		viewMap.put(MessageTypeEnum.LEFT_IMAGE.getTypeNo(),
				new LeftImageMessage());
		viewMap.put(MessageTypeEnum.RIGHT_IMAGE.getTypeNo(),
				new RightImageMessage());
		viewMap.put(MessageTypeEnum.LEFT_AUDIO.getTypeNo(),
				new LeftAudioMessage());
		viewMap.put(MessageTypeEnum.RIGHT_AUDIO.getTypeNo(),
				new RightAudioMessage());
		

	}

	public static View getMessageView(Context context,
			TapLinkerMessage message, View convertView) {
		AbstractMessageView messageView = null;
		messageView = viewMap.get(MessageTypeEnum.getMessageType(message)
				.getTypeNo());
		return messageView.getMessageView(context, message, convertView);
	}
}
